package net.esj.basic.core.view.tools.searcher;

import net.esj.basic.utils.StringUtils;

import org.apache.commons.lang.RandomStringUtils;

public class SearcherColumn {

	private String id;
	
	//字段名
	private String key;
	
	//显示名称
	private String view;
	
	//搜索值
	private Object value;
	
	/**
	 * 查询类型
	 * eg : equal like 等
	 */
	private String type;
	
	private int order = Integer.MAX_VALUE;
	
	public SearcherColumn() {
		super();
	}

	public SearcherColumn(String key, String view, Object value) {
		super();
		this.key = key;
		this.view = view;
		this.value = value;
		this.id = genId();
	}
	
	
	public SearcherColumn(String key, String view, Object value,int order) {
		super();
		this.key = key;
		this.view = view;
		this.value = value;
		this.id = genId();
		this.order = order;
	}
	
	public SearcherColumn(String key, String view,String type, Object value) {
		super();
		this.key = key;
		this.view = view;
		this.value = value;
		this.type = type;
		this.id = genId();
	}
	
	public SearcherColumn(String key, String view, String type,Object value,int order) {
		super();
		this.key = key;
		this.view = view;
		this.value = value;
		this.type = type;
		this.id = genId();
		this.order = order;
	}

	public SearcherColumn(String id, String key,String type, String view, Object value) {
		super();
		this.id = id;
		this.key = key;
		this.view = view;
		this.type = type;
		this.value = value;
	}
	
	public SearcherColumn(String id, String key,String type, String view, Object value,int order) {
		super();
		this.id = id;
		this.key = key;
		this.view = view;
		this.value = value;
		this.type = type;
		this.order = order;
	}

	public String getId() {
		return id;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
		this.id = genId();
	}

	public String getView() {
		return view;
	}

	public void setView(String view) {
		this.view = view;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}
	
	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	private String genId() {
	        String id =StringUtils.longToN36(System.currentTimeMillis());
	        return id+"-"+RandomStringUtils.random(6, StringUtils.getN36Chars())+"-"+key;
	  }
}
